package com.office.supplies.mapper;

import com.office.supplies.pojo.Goods;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @Author admin
 * @Description TODO
 * @Date 2023/12/11/0:52
 */
@Mapper
public interface GoodsMapper {

    /**
     * 新增商品
     *
     * @param goods Goods
     */
    @Insert("insert into goods (goods_code,goods_name, goods_address, goods_desc, goods_price, goods_unit, goods_img) " +
            "value (#{goodsCode},#{goodsName},#{goodsAddress},#{goodsDesc},#{goodsPrice},#{goodsUnit},#{goodsImg})")
    void insertGoods(Goods goods);

    /**
     * 根据id删除商品
     *
     * @param id Long
     */
    @Delete("delete from goods where id = #{id}")
    void deleteGoodsById(Long id);

    /**
     * 修改商品
     *
     * @param goods Goods
     */
    void updateGoods(Goods goods);

    /**
     * 模糊条件查询商品
     *
     * @param goods Goods
     * @return List<Goods>
     */
    List<Goods> getGoodsList(Goods goods);

    @Select("select * from goods where id = #{goodsId}")
    Goods selectById(Long goodsId);
}
